This section contains coding hints that increase optimization for the other passes of the compiler.
typedef enum { BLUE, GREEN, RED, NCOLORS } COLOR;
Instead of:
switch ( c ) {
case CASE0: x = 5; break;
case CASE1: x = 10; break;
case CASE2: x = 1; break;
}
Use:
static int Mapping[NCOLORS] = { 5, 10, 1 };
...
x = Mapping[c];
double d;
unsigned int u;
int i;
/* fast */ d = i;
/* fast */ d = (int)u;
/* slow */ d = u;
Converting an unsigned type to floating-point takes significantly longer than converting signed types to floating-point; additional software support must be generated in the instruction stream for the former case.
unsigned int ui;
signed int i;
long int li;
/* fast */ li += i;
/* fast */ li += (int)ui;
/* slow */ li += ui;